package com.base.monitor.admin.controller.system;

import com.base.monitor.framework.annotation.RefuseResponseResult;
import com.base.monitor.framework.annotation.ResponseResult;
import com.base.monitor.framework.result.PageResult;
import com.base.monitor.model.model.system.criteria.UserCriteria;
import com.base.monitor.model.model.system.dto.UserSaveDto;
import com.base.monitor.model.model.system.entity.User;
import com.base.monitor.module.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @description:
 * @author: tsing
 * @create: 2021-01-22 20:35
 */
@RestController
@RequestMapping("/sys/user")
@ResponseResult
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 分页查询用户信息
     * @param userCriteria 查询条件
     * @return
     */
    @GetMapping
    @RefuseResponseResult
    public PageResult<User> page(UserCriteria userCriteria) {
        return userService.page(userCriteria);
    }

    /**
     * 更新用户信息
     * @param userSaveDto 用户信息
     */
    @PutMapping
    public void edit(@Valid @RequestBody UserSaveDto userSaveDto) {
        userService.edit(userSaveDto);
    }

}
